<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <th:block th:replace="fragments/head :: public-css"/>
    <th:block th:replace="fragments/head :: bootstrap-table-css"/>
</head>

<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed">
<!-- Site wrapper -->
<div class="wrapper">

    <!-- 头部区域 Navbar -->
    <th:block th:replace="fragments/main-header"/>

    <!-- 左侧区域 Main Sidebar Container -->
    <th:block th:replace="fragments/main-sidebar(activeUrl='/permission')"/>

    <!-- 内容区域 start-->
    <div class="content-wrapper text-sm">

        <!-- 内容头部 -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>菜单管理</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">系统管理</a></li>
                            <li class="breadcrumb-item active">菜单管理</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">
            <!-- .box-body -->
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">菜单列表</h3>
                    <!-- 工具栏 -->
                    <div class="card-tools">
                        <button sec:authorize="hasAuthority('sys:permission:add')" type="button"
                                class="btn btn-primary btn-xs"
                                th:onclick="location.href=[[@{/permission/form}]]" data-toggle="tooltip" title="新增">
                            <i class="fa fa-plus"></i>&nbsp;新增
                        </button>
                    </div>
                    <!-- /工具栏 -->
                </div>
                <div class="card-body">
                    <table id="table" class="table table-bordered"></table>
                </div>
            </div>
            <!--/.box-body-->
            <!--盒子内容-->

        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- 内容区域 end-->

    <!--右底部区域-->
    <th:block th:replace="fragments/main-footer"/>

    <!-- 右上角工具栏 Control Sidebar -->
    <th:block th:replace="fragments/control-sidebar"/>

    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<th:block th:replace="fragments/script :: public-js"/>
<th:block th:replace="fragments/script :: bootstrap-table-js"/>
<th:block th:replace="fragments/script :: layer-js"/>
<!--公共的js-->
<script th:src="@{/modules/js/common.js}"></script>
<!--权限资源列表js-->
<script th:src="@{/modules/js/permission/permission-list.js}"></script>
<script th:inline="javascript">
    function getOperationHtml(operationHtml, row) {

        if (/*[[${#authorization.expression('hasAuthority("sys:permission:edit")')}]]*/) {
            operationHtml.push('<li><a href="' + contextPath + 'permission/form/' + row.id + '" class="dropdown-item btn btn-primary"><i class="fa fa-edit"></i>&nbsp;修改</a></li>')
        }

        if (/*[[${#authorization.expression('hasAuthority("sys:permission:delete")')}]]*/) {
            operationHtml.push('<li><a onclick="$.delete(\'' + contextPath + 'permission/' + row.id + '\')" class="dropdown-item btn btn-primary"><i class="fa fa-trash"></i>&nbsp;删除</a></li>')
        }

    }

    // 权限判断是否显示操作列
    function showOperation() {
        if (
            /*[[
            ${#authorization.expression('hasAuthority("sys:permission:delete")')}
            or ${#authorization.expression('hasAuthority("sys:permission:edit")')}
            ]]*/
        ) {
            $table.bootstrapTable('showColumn', 'action')
        }
    }
</script>

</body>
</html>